﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using System.Xml.Serialization;

namespace ServerExplorer.SharePointConnections.SharepointSiteInfo.Entities
{
    [Serializable]
    public class Folder
    {
        private string _relativeUrl;

        private string _guid;

        [XmlAttribute("Name")]
        public string RelativeUrl
        {
            get { return _relativeUrl; }
            set { _relativeUrl = value; }
        }

        [XmlAttribute("Guid")]
        public string Guid
        {
            get { return _guid; }
            set { _guid = value; }
        }

        private string _internalColor = System.Drawing.Color.Blue.Name;

        [XmlAttribute("Color")]
        public string InternalColor
        {
            get { return _internalColor; }
            set
            {
                //Do Nothing 
            }
        }

        
        private List<Page> _pages;

        [XmlElement("Page")]
        public List<Page> Pages
        {
            get { return _pages; }
            set { _pages = value; }
        }

        private List<Folder> _subFolder;

        [XmlElement("SubFolder")]
        public List<Folder> SubFolder
        {
            get { return _subFolder; }
            set { _subFolder = value; }
        }
                        
        private Folder(String[] obj)
            : this()
        {
            _relativeUrl = obj[0];
            _guid = obj[1];
        }

        private Folder(string val)
            : this()
        {
            _relativeUrl = val;
        }

        public Folder()
        {
            Pages = new List<Page>();
            SubFolder = new List<Folder>();
        }

        public static implicit operator Folder(string obj)
        {
            return new Folder(obj);
        }

        public static implicit operator Folder(String[] obj)
        {
            return new Folder(obj);
        }

        public override string ToString() { return RelativeUrl; }
    }
}
